<template>
  <div class="api">
    <button @click="getUsers">请求数据</button>
    <template v-for="(item, index) in list">
      <div class="userinfo">
        <div class="name">{{ item.username }}</div>
        <div class="department">{{ item.departmentName }}</div>
        <div class="mobile">{{ item.mobile }}</div>
      </div>
    </template>
  </div>
</template>

<script>
import { request } from "@/request/index";

export default {
  data() {
    return {
      list: [],
    };
  },
  created() {},
  methods: {
    async getUsers() {
      const res = await request.get("/userInfo");
      this.list = res.data.rows;
    },
  },
};
</script>

<style scoped></style>